
def isPerfectNumber(n):
    if n <= 1:
        return False
    
    sum_factors = 0  
    for i in range(1, n // 2 + 1):
        if n % i == 0:  
            sum_factors += i  
    return sum_factors == n